package com.example.socket.server;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;


/**
 * @author xiaocg
 */
public class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //添加编解码
        socketChannel.pipeline().addLast(new LengthFieldBasedFrameDecoder(16*1024*1024,8,4,0,0));
        socketChannel.pipeline().addLast(new MyMessageEncode());
        socketChannel.pipeline().addLast(new NettyServerHandler());
    }
}
